// document new node
var docNode = function(targetNode, element){
	if(!element) return false;
	var node = document.createElement(element);
	var insert = "after";
	for(var t=2; t<arguments.length; t=t+2){
		if(browser.isIE){
			arguments[t] = arguments[t].toLowerCase();
			switch(arguments[t]){
				case "class":
					node.setAttribute('className', arguments[t+1]);
					break;
				case "style":
					var styles = arguments[t+1].split(" ").join("").split(";");
					if(styles[styles.length - 1] == "") styles.pop();
					for(var s=0; s<styles.length; s++){
						var style = styles[s].split(":");
						node.style[style[0]] = style[1];
					}
					break;
				case "onclick":
					node[arguments[t]] = eval("new Function('" + arguments[t+1] + "')");
					break;
				case "onmouseover":
					node[arguments[t]] = eval("new Function('" + arguments[t+1] + "')");
					break;
				case "onmouseout":
					node[arguments[t]] = eval("new Function('" + arguments[t+1] + "')");
					break;
				case "onchange":
					node[arguments[t]] = eval("new Function('" + arguments[t+1] + "')");
					break;
				case "insert":
					insert = arguments[t+1];
					break;
				default:
					node.setAttribute(arguments[t], arguments[t+1]);
					break;
			};
		}
		else if(arguments[t] == "insert") insert = arguments[t+1];
		else node.setAttribute(arguments[t], arguments[t+1]);
	}
	if(typeof(targetNode) == "string") targetNode = docId(targetNode);
	if(typeof(targetNode) == "undefined") return false;
	if(insert == "before") targetNode.insertBefore(node, targetNode.firstChild);
	else if(!isNaN(insert)) targetNode.insertBefore(node, targetNode.childNodes[parseInt(insert)]);
	else targetNode.appendChild(node);
	return node;
};
